package com.ht.psplan;

import java.util.StringTokenizer;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.io.Serializable;

/**
 * class PlanInfo
 * <p> plan information card <br>
 * @author Dong Shufeng
 * @Date: 2006-9-21
 * @version 1.0
 */
public class PlanInfo implements Serializable {
    public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    private int id;

    private int planId;

    private Date date;

    private Date lastSuccessTime;

    private String content;

    private int length;

    public PlanInfo() {
    }

    public PlanInfo(int length) {
        this.length = length;
    }

    public PlanInfo(int id, int length) {
        this(length);
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    /**
     *
     * @return example: 2006-08-08-07-05
     */
    public Date getLastSuccessTime() {
        return lastSuccessTime;
    }

    /**
     *
     * @param lastSuccessTime example: 2006-08-08-07-05
     */
    public void setLastSuccessTime(Date lastSuccessTime) {
        this.lastSuccessTime = lastSuccessTime;
    }

    public int getPlanId() {
        return planId;
    }

    public void setPlanId(int planId) {
        this.planId = planId;
    }

    public Date getDate() {
        return date;
    }

    /**
     * dateformat is 2006-08-08
     * @param date
     */
    public void setDate(Date date) {
        this.date = date;
    }

    public void setDate(long date) {
        //setDate(dateFormat.format(date));
        setDate(new Date(date));
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public double[] getValues() {
        StringTokenizer tokenizer = new StringTokenizer(content, ";");
        double[] values = new double[tokenizer.countTokens()];
        for(int i = 0; i < values.length; i++)
            values[i] = Double.parseDouble(tokenizer.nextToken());
        return values;
    }
}
